<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>变量解构赋值</title>
</head>
<body>
    <script>
        // 解构赋值
        let arr = [1,2,3,4]
        let [a,b,...c] = arr
        console.log('a=',a ,' b=',b,' c=',c );
   
        // 在解构赋值的时候，可以给变量设置默认值
        let [d = 2,e = 20] = [10]
        console.log('d = ',d,' e = ',e);

        let obj = {
            name: 'zs',
            age: 18

        }
        let {name,age} = obj
        console.log('name = ',name, ' age = ',age);

        // 重名，那么此时name和age就没有用了
        let {name:Name,age:Age} = obj
        console.log('Name = ',Name,' Age = ',Age);
    </script>
</body>
</html>